package com.sfzd5.UI.answersheet;

import com.sfzd5.exam.helplibrary.exam.answersheet.ExpoundChildQuestion;

import javax.swing.*;

public class ExpoundChildEditBar extends AnswerSheetQuestionEditBar {
    JCheckBox cb_withLine;
    JSpinner sp_score;
    JSpinner sp_lineNum;

    ExpoundChildQuestion expoundChildQuestion;
    public ExpoundChildEditBar(ExpoundChildQuestion expoundChildQuestion){
        super();

        this.expoundChildQuestion = expoundChildQuestion;

        cb_withLine = new JCheckBox("行线条");
        cb_withLine.setSelected(this.expoundChildQuestion.withLine);
        this.add(cb_withLine);

        JLabel lb_width = new JLabel("宽度");
        this.add(lb_width);

        sp_lineNum = new JSpinner();
        SpinnerNumberModel widthSpinnerNumberModel = new SpinnerNumberModel();
        widthSpinnerNumberModel.setMinimum(1);
        widthSpinnerNumberModel.setMaximum(100);
        widthSpinnerNumberModel.setStepSize(1);
        sp_lineNum.setModel(widthSpinnerNumberModel);
        sp_lineNum.setValue(this.expoundChildQuestion.lineNum);
        this.add(sp_lineNum);


        JLabel lb_score = new JLabel("分值");
        this.add(lb_score);

        sp_score = new JSpinner();
        SpinnerNumberModel spinnerNumberModel = new SpinnerNumberModel();
        spinnerNumberModel.setMinimum(1);
        spinnerNumberModel.setMaximum(100);
        spinnerNumberModel.setStepSize(1);
        sp_score.setModel(spinnerNumberModel);
        sp_score.setValue(this.expoundChildQuestion.score);
        this.add(sp_score);
    }

    public ExpoundChildQuestion getExpoundChildQuestion(){
        this.expoundChildQuestion.withLine = cb_withLine.isSelected();
        this.expoundChildQuestion.lineNum = (int) sp_lineNum.getValue();
        this.expoundChildQuestion.score = (int) sp_score.getValue();
        return this.expoundChildQuestion;
    }
}
